import requestMeeting, { request } from '@/plugins/axios'
import { FetchTemplateParams, FetchTemplatesData, TemplatesParams } from './interface'
/** 获取个人会议模板列表 */
export const fetchGetPersonalTemplates = async (params: TemplatesParams) =>
	request<FetchTemplatesData>({
		url: '/personal_templates',
		method: 'get',
		params: params,
	}).then((res) => (res.success ? { data: res.personal_templates, total: res.total } : undefined))

/** 获取个人会议模板 */
export const fetchGetPersonalTemplate = async (id: string) =>
	request<FetchTemplateParams>({
		url: `/personal_templates/${id}`,
		method: 'get',
	}).then((res) => res)

/** 删除个人会议模板 */
export const fetchDeletePersonalTemplates = async (ids: string[]) =>
	requestMeeting({
		url: '/personal_templates',
		method: 'DELETE',
		data: ids,
	}).then((res) => res)

/** 获取机房信息 */
export const fetchGetMachineRooms = async () =>
	requestMeeting<
		{
			moid: string
			name: string
		}[]
	>({
		url: '/all_machine_room',
		method: 'get',
	}).then((res) => (res.success && res.data ? res.data : undefined))

/** 获取个人会议模板 */
export const fetchGetKeyAfterImport = async (key: string, template_moid: string) =>
	requestMeeting<string>({
		url: `/meeting/import_pres?key=${key}&template_moid=${template_moid}`,
		method: 'get',
	}).then((res) => (res.success && res.data ? res.data : ''))
